package licode;

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;

public class L128 {
    public static int longestConsecutive(int[] nums) {
        if (nums == null || nums.length == 0) {
            return 0;
        }
        Arrays.sort(nums);
        int result=1;
        int current=1;
        for (int i=1;i<nums.length;i++){
            if (nums[i]==nums[i-1]+1){
                current++;
            }else {
                current=1;
            }
            result=Math.max(result,current);
        }
        return result;

    }

    public static void main(String[] args) {
        int[] arr1={100,4,200,1,1,3,2,2};
        int i = longestConsecutive(arr1);
        System.out.println(i);
    }
}
